<#include "includemenu.html"/>
<div class="rs_layout_top breadCrumbWrap">
	<div class="breadCrumbStart">您当前的位置是在：</div>
	<ul class="breadCrumb">
		<li class="bc_ithems"><a href="/${orgi}/manage/task/taskpassing.html">系统管理</a></li>
		<li class="bc_ithems"><a href="/${orgi}/manage/system/index.html">系统设置</a></li>
	</ul>
	<#if ex??>
	<ul class="controlButtons">
		<li class="cbtn-icon-43" data-toggle="ajax" id="newreport" href="/${orgi}/manage/system/${type!''}/propertiessettingadd.html<#if ex??>?ex=true</#if>" data-width="480" title="添加字典项"></li>
		<li class="cbtn-icon-49"><a href="/${orgi}/manage/system/export.html" target="_blank" title="导出配置信息"><i class="tbControlIcon "></i></a></li>
	</ul>
	</#if>
</div>
<div class="rs_layout_left" resizable="true" style="width:230px;">
	<div class="lftTreeWrap">
		<div class="ztree" id="zTree_adminLIst"></div>
	</div>
</div>
<SCRIPT type="text/javascript">
	$(document).ready(function(){
		ztree.selectNode(ztree.getNodeByParam("id", "${type!''}", null));
	});
	function dblclick(id,paramtype,paramvalue,value){
		var type = paramtype;
		var va = ""; 
		//获取上次双击选中的id和值
		var sid = $("#hid_id").val();
		if(sid == id){
			return;
		}
		var sval = $("#hid_val").val();
		value = $("#div_"+id).html().trim();
		//将本次选中的id赋值到隐藏域中
		$("#hid_id").val(id);
		$("#hid_val").val(value);
		//文本框
		if(type == null || type== "" || type == undefined || type =="1"){
			if(value==""  || value==undefined || value == null){
				va = "<input type ='text' name = 'value' style='padding:0px;width:300px' value = '' id = "+id+" onkeypress='keypress()' onblur='mouseclick()'>";
			}else{
				va = "<input type ='text' name = 'value' style='padding:0px;width:300px' value = "+value+" id = "+id+" onkeypress='keypress()' onblur='mouseclick()'>";
			}
		//下拉框	
		}else if (type == "2"){
			if(paramvalue != null || paramvalue != "" || paramvalue != undefined){
				var pva =  paramvalue.split(",");
				var con = "";
				for(var i = 0 ; i < pva.length ; i ++){
					var paramv = pva[i].split(":");
					if(paramv.length>=2){
						if(value == paramv[0]){
							con += "<option value = "+paramv[0]+" selected = 'selected'>"+paramv[1]+"</option>";
						}else{
							con += "<option value = "+paramv[0]+">"+paramv[1]+"</option>";
						}
					}else{
						if(value == pva[i]){
							con += "<option value = "+pva[i]+"  selected = 'selected'>"+pva[i]+"</option>";
						}else{
							con += "<option value = "+pva[i]+">"+pva[i]+"</option>";
						}
					}
				}
				va = "<select name = 'value' style='padding:0px;height:20px' onchange='change()' id = 'select' onblur='mouseclick()'>"+con+
				"</select><input type ='hidden' name = 'value' style='padding:0px;width:300px' value = "+value+" id = "+id+">";
			}
		//颜色
		}else if (paramtype == "3"){
			va = "<blockquote><input type ='text' name = 'value' class='colorpicker' style='padding:0px;width:300px' value = "+value+" id = "+id+" onkeypress='keypress()' ></blockquote>";
		//日历
		}else if (paramtype == "4"){
		
		}
		if(sid != "" || sid != null || sid != undefined){
			$("#div_"+sid).html(sval);
		}
		$("#div_"+id).html(va);
		//获取焦点
		$("#"+id).val("").focus().val(value);
		//给颜色选择器绑定颜色空间，其他的事件不绑定
		if(type == "3"){
			//绑定颜色选择器
			$("#"+id).colorpicker({
				fillcolor:true,
	    		target:$("#"+id),
	    		success:function(){
	    			mouseclick();
	    		}
			}); 
		}
	}
	
	function mouseclick(){
		var sid = $("#hid_id").val();
		var sval = $("#hid_val").val();
		change();
		var value = $("#select").val();
		if(value == null || value == "" || value ==undefined){
			value = $("#"+sid).val();
		}
		if(value == sval){
			if(sid != "" || sid != null || sid != undefined){
				$("#div_"+sid).html(sval);
			}
			$("#hid_id").val("");
		}
	}
	function change(){
		var id = $("#hid_id").val();
		$("#p_id").val(id);
		var value = $("#select").val();
		if(value == null || value == "" || value ==undefined){
			value = $("#"+id).val();
		}
		$("#p_value").val(value);
		var sval = $("#hid_val").val();
		
		if(sval != value){
			loadURL("/${orgi}/manage/system/${type}/propertiessettingeditdof.html?id="+id+"&value="+encodeURIComponent(value),"#tempdiv",
			function(propertiesList){
				var sid = $("#hid_id").val();
				if(sid != "" || sid != null || sid != undefined){
					$("#div_"+sid).html(value);
					$("#hid_val").val(value);
					$("#hid_id").val("");
				}
			});
		}
		
	}
	
	//执行回车事件
	document.keypress =  function(event){
		var e = event || window.event || arguments.callee.caller.arguments[0];
		if(e.keyCode == 13){
			var id = $("#hid_id").val();
			$("#p_id").val(id);
			var value = $("#select").val();
			if(value == null || value == "" || value ==undefined){
				value = $("#"+id).val();
			}
			$("#p_value").val(value);
			var sval = $("#hid_val").val();
			if(sval != value){
				loadURL("/${orgi}/manage/system/${type}/propertiessettingeditdof.html?id="+id+"&value="+encodeURIComponent(value),"#tempdiv",
				function(data){
					var sid = $("#hid_id").val();
					var sval = $("#hid_val").val();
					if(sid != "" || sid != null || sid != undefined){
						$("#div_"+sid).html(value);
						$("#hid_val").val(value);
						$("#hid_id").val("");
					}
				});
			}
			//$("#mainForm").submit();
		}
	}
function controlDiv(id){
	if($("#but"+id).hasClass("a_close")){
		$("#"+id).slideUp(50);
		$("#but"+id).attr("class","tbControlIcon a_open");
	}else{
		$("#"+id).slideDown(50);
		$("#but"+id).attr("class","tbControlIcon a_close");
	}
} 
//单选框和复选框选中后提交数据值
function submit(id,type,obj){
	var value = "";
	if(type == "radio"){
		value = obj.defaultValue;
	}else{
		var str=document.getElementsByName(id);
		var objarray=str.length;
		for (i=0;i<objarray;i++){
			value +=str[i].value+","
		}
	}
	
	loadURL("/${orgi}/manage/system/${type}/propertiessettingeditdof.html?id="+id+"&value="+encodeURIComponent(value),"#tempdiv",
	function(data){});
}
</SCRIPT>

<!--<div class="rs_layout_right" style="width:300px;"></div>-->
<form class="form-horizontal" id="mainForm" data-toggle="ajax" action="/${orgi}/manage/system/${type}/propertiessettingeditdof.html" method="post">
<input type="hidden" name = "id" id = "p_id"/>
<input type="hidden" name = "value" id = "p_value"/>

</form>
<input type ="hidden" value = "" id = "hid_id" />
<input type ="hidden" value = "" id = "hid_val" />
<div class="rs_layout_center">
	<div class="rs_layout">
		<div class="rs_layout_center">
			<div class="tableScrollWrap">
				 <table class="table_style_1">
					<thead>
						<tr>
							<th style="width:50px;">&nbsp;</th>
							<th style="width:240px;">参数名称</th>
							<#if ex??>
							<th style="width:240px;">参数代码</th>
							</#if>
							<th>值</th>
							<th style="width:16px;">&nbsp;</th>
							<th style="width:50px;">&nbsp;</th>
							<#if ex??>
							<th class="minSize"></th>
							</#if>
							
						</tr>
					</thead>
					<#if datas ??>
						<#list datas as da>
							<tbody>
								<#if !da.groupid ?? || da.groupid =="">
								<tr>
									<#if ex ??>
										<td class="minSize" style="border-bottom:1px solid #cccccc;">
											<a href="#" onclick="controlDiv('${da.id}')">
												<i id="but${da.id}" class="tbControlIcon a_close" style="height:16px;width:16px"></i>
											</a>
										</td>
										<td colspan="6" style="border-bottom:1px solid #cccccc;"><h4>${da.title!""}</h4></td>
									<#else>
										<td class="minSize" style="border-bottom:1px solid #cccccc;">
											<a href="#" onclick="controlDiv('${da.id}')">
												<i id="but${da.id}" class="tbControlIcon a_close" style="height:16px;width:16px"></i>
											</a>
										</td>
										<td colspan="4" style="border-bottom:1px solid #cccccc;"><h4>${da.title!""}</h4></td>
									</#if>
								</tr>
								</#if>
							</tbody>
							<tbody id="${da.id}">
								<tr>
									<#if propertiesList??>
										<#list propertiesList as properties>
										<#assign templateSource = "${properties.groupid!''}"> 
										<#if da.name ?? && da.name = templateSource>
										<tr>
											<td class="minSize"><#if properties.levels?? && properties.levels=="1"><div style="font-weight:bold;color:red;font-size:18px;">*</div></#if></td>
											<td style="width:240px;">
												${properties.title!''}
											</td>
											<#if ex??>
											<td style="width:240px;">
												${properties.name!''}
											</td>
											</#if>
											<#if ex??>
												<td style="width:840px;"><#if properties.value?? && properties.value?length gt 50>${properties.value[0..50]}<#else>${properties.value!''}</#if></td>
											<#else>
												<#if properties.paramtype ?? && (properties.paramtype == "5" || properties.paramtype == "6"|| properties.paramtype == "7"|| properties.paramtype == "8")>
													<td style="width:840px;">
														<#if properties.paramtype == "7" || properties.paramtype == "8">
															<SCRIPT type="text/javascript">
																$(document).ready(function(){
																	var id =  "${properties.id}";
																	var paramtype = "${properties.paramtype}";
																	var paramvalue = "${properties.paramvalue}";
																	var value = "${properties.value!''}";
																	var type = "radio";
																	if(paramtype == "8"){
																		type = "checkbox"
																	}
																	if(paramvalue != null || paramvalue != "" || paramvalue != undefined){
																		var pva =  paramvalue.split(",");
																		var con = "";
																		for(var i = 0 ; i < pva.length ; i ++){
																			var paramv = pva[i].split(":");
																			if(paramv.length>=2){
																				if(value == paramv[0]){
																					con += "<label><input id ="+i+" type="+type+" name = "+id+" value = "+paramv[0]+" checked = 'checked' onclick='submit(\""+id+"\",\""+type+"\",this)'>"+paramv[1]+"</label>";
																				}else{
																					con += "<label><input id ="+i+" type="+type+" name = "+id+" value = "+paramv[0]+"  onclick='submit(\""+id+"\",\""+type+"\",this)'>"+paramv[1]+"</label>";
																				}
																			}else{
																				if(value == pva[i]){
																					con += "<label><input id ="+i+" type="+type+" name = "+id+" value = "+pva[i]+"  checked = 'checked'  onclick='submit(\""+id+"\",\""+type+"\",this)'>"+pva[i]+"</label>";
																				}else{
																					con += "<label><input id ="+i+" type="+type+" name = "+id+" value = "+pva[i]+"  onclick='submit(\""+id+"\",\""+type+"\",this)'>"+pva[i]+"</label>";
																				}
																			}
																		}
																	}
																	$("#radioorcheck"+id).html(con);
																});
															</SCRIPT>	
															<div id ="radioorcheck${properties.id}"></div>
														<#else>
															<#if properties.value?? && properties.value?length gt 50>${properties.value[0..50]}<#else>${properties.value!''}</#if>
														</#if>
													</td>
												<#else>
													<td style="width:840px;" ondblclick="dblclick('${properties.id!""}','${properties.paramtype!""}','${properties.paramvalue!""}','${properties.value!""}')">
														<div id = "div_${properties.id}" >
															<#if properties.value?? && properties.value?length gt 50>${properties.value[0..50]}<#else>${properties.value!''}</#if>
														</div>
													</td>
												</#if>
											</#if>
											<td style="width:50px;">
												<a href="/${orgi}/manage/task/searchsettingadd/${properties.name!''}/${type}.html" data-toggle="ajax" title="预警">
													<#if properties.earlywarning ?? &&  properties.earlywarning == "1">
														<i class="tbControlIcon top_icon122"></i>
													</#if>
												</a>
											</td>
											<td style="width:350px;" title="${properties.description!''}">
												<#if properties.earlywarning ?? &&  properties.earlywarning == "1" && properties.description??>
													<#if properties.description?length gt 20>${properties.description[0..20]}<#else>${properties.description!''}</#if>
												</#if>
											</td>
											<#if ex??>
											<td class="minSize">
												<a href="/${orgi}/manage/system/${type!''}/propertiessettingedit/${properties.id!''}.html<#if ex??>?ex=true</#if>" data-width="480" data-toggle="ajax" title="编辑"><i class="tbControlIcon tci-105"></i></a>
												<a href="/${orgi}/manage/system/${type!''}/propertiessettingdel/${properties.id!''}.html<#if ex??>?ex=true</#if>" data-toggle="delete" data-title="请确认是否删除参数？" title="删除${properties.title!''}"> <i class="tbControlIcon tci-104"></i> </a>
				
												<a href="/${orgi}/manage/system/${type!''}/propertiessettingcode/${properties.id!''}.html<#if ex??>?ex=true</#if>" data-toggle="ajax" title="编辑${properties.title!''}"><i class="tbControlIcon tci-102"></i></a>
											</td>
											</#if>								
										</tr>
										</#if>
										</#list>
									</#if>
								</tr>
								<#if configdatas ??>
								<#list configdatas as con>
								<#assign template = "${con.groupid}"> 
								<#if da.name ?? && da.name = template>
								<tr>
									<#if ex ??>
										<td class="minSize"></td>
										<td colspan="6" style="border-bottom:1px solid #cccccc;"><h4>${con.title!""}</h4></td>
									<#else>
										<td class="minSize"></td>
										<td colspan="4" style="border-bottom:1px solid #cccccc;"><h4>${con.title!""}</h4></td>
									</#if>
								</tr>
								</#if>
								</#list>
								</#if>
							</tbody>
						</#list>
					<#else>
						<tbody>
							<#if propertiesList??>
								<#list propertiesList as properties>
								<tr>
									<td class="minSize"><#if properties.levels?? && properties.levels=="1"><div style="font-weight:bold;color:red;font-size:18px;">*</div></#if></td>
									<td style="width:240px;">
										${properties.title!''}
									</td>
									<#if ex??>
									<td style="width:240px;">
										${properties.name!''}
									</td>
									</#if>
									
									<#if ex??>
										<td style="width:840px;"><#if properties.value?? && properties.value?length gt 50>${properties.value[0..50]}<#else>${properties.value!''}</#if></td>
									<#else>
										<#if properties.paramtype ?? && (properties.paramtype == "5" || properties.paramtype == "6"|| properties.paramtype == "7"|| properties.paramtype == "8")>
											<td style="width:840px;">
											<#if properties.paramtype == "7" || properties.paramtype == "8">
												<SCRIPT type="text/javascript">
													$(document).ready(function(){
														var id =  "${properties.id}";
														var paramtype = "${properties.paramtype}";
														var paramvalue = "${properties.paramvalue}";
														var value = "${properties.value}";
														var type = "radio";
														if(paramtype == "8"){
															type = "checkbox"
														}
														if(paramvalue != null || paramvalue != "" || paramvalue != undefined){
															var pva =  paramvalue.split(",");
															var con = "";
															for(var i = 0 ; i < pva.length ; i ++){
																var paramv = pva[i].split(":");
																if(paramv.length>=2){
																	if(value == paramv[0]){
																		con += "<label for="+i+"><input id ="+i+" type="+type+" name = "+id+" value = "+paramv[0]+" checked = 'checked' onclick='submit(\""+id+"\",\""+type+"\",this)'>"+paramv[1]+"</label>";
																	}else{
																		con += "<label for="+i+"><input id ="+i+" type="+type+" name = "+id+" value = "+paramv[0]+"  onclick='submit(\""+id+"\",\""+type+"\",this)'>"+paramv[1]+"</label>";
																	}
																}else{
																	if(value == pva[i]){
																		con += "<label for="+i+"><input id ="+i+" type="+type+" name = "+id+" value = "+pva[i]+"  checked = 'checked'  onclick='submit(\""+id+"\",\""+type+"\",this)'>"+pva[i]+"</label>";
																	}else{
																		con += "<label for="+i+"><input id ="+i+" type="+type+" name = "+id+" value = "+pva[i]+"  onclick='submit(\""+id+"\",\""+type+"\",this)'>"+pva[i]+"</label>";
																	}
																}
															}
														}
														$("#radioorcheck"+id).html(con);
													});
												</SCRIPT>	
												<div id ="radioorcheck${properties.id}"></div>
											<#else>
												<#if properties.value?? && properties.value?length gt 50>${properties.value[0..50]}<#else>${properties.value!''}</#if>
											</#if>
											</td>
										<#else>
											<td style="width:840px;" ondblclick="dblclick('${properties.id!""}','${properties.paramtype!""}','${properties.paramvalue!""}','${properties.value!""}')">
												<div id = "div_${properties.id}" >
													<#if properties.value?? && properties.value?length gt 50>${properties.value[0..50]}<#else>${properties.value!''}</#if>
												</div>
											</td>
										</#if>
									</#if>
									<td style="width:50px;">
										<a href="/${orgi}/manage/task/searchsettingadd/${properties.name!''}/${type}.html" data-toggle="ajax" title="预警">
											<#if properties.earlywarning ?? &&  properties.earlywarning == "1">
												<i class="tbControlIcon top_icon122"></i>
											</#if>
										</a>
									</td>
									<td style="width:350px;" title="${properties.description!''}">
										<#if properties.earlywarning ?? &&  properties.earlywarning == "1" && properties.description??>
											<#if properties.description?length gt 20>${properties.description[0..20]}<#else>${properties.description!''}</#if>
										</#if>
									</td>
									<#if ex??>
									<td class="minSize">
										<a href="/${orgi}/manage/system/${type!''}/propertiessettingedit/${properties.id!''}.html<#if ex??>?ex=true</#if>" data-width="480" data-toggle="ajax" title="编辑"><i class="tbControlIcon tci-105"></i></a>
										<a href="/${orgi}/manage/system/${type!''}/propertiessettingdel/${properties.id!''}.html<#if ex??>?ex=true</#if>" data-toggle="delete" data-title="请确认是否删除参数？" title="删除${properties.title!''}"> <i class="tbControlIcon tci-104"></i> </a>
		
										<a href="/${orgi}/manage/system/${type!''}/propertiessettingcode/${properties.id!''}.html<#if ex??>?ex=true</#if>" data-toggle="ajax" title="编辑${properties.title!''}"><i class="tbControlIcon tci-102"></i></a>
									</td>
									</#if>								
								</tr>
								</#list>
							</#if>
						</tbody>
					</#if>
				</table>
			</div>
		</div>
	</div>
</div>